package softtech.apps.callblocker.model;

import android.content.ContentValues;
import android.database.Cursor;

public class CallBlockedItem {
	
	public  static final String TABLE_NAME = "CallBlockedItem";
	private int id;
	public static final String ID = "id";
	
	private String phoneNumber;
	public static final String PHONE_NUMBER = "phoneNumber";

	private String date_time;
	public static final String DATE_TIME = "date_time";

	private int status;
	public static final String STATUS = "status";
	
	public CallBlockedItem() {
		super();
		// TODO Auto-generated constructor stub
	}
	public CallBlockedItem(int id, String phoneNumber, String date_time,
			int status) {
		super();
		this.id = id;
		this.phoneNumber = phoneNumber;
		this.date_time = date_time;
		this.status = status;
	}
	public CallBlockedItem( String phoneNumber, String date_time,
			int status) {
		super();
		this.phoneNumber = phoneNumber;
		this.date_time = date_time;
		this.status = status;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getPhoneNumber() {
		return phoneNumber;
	}
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	public String getDate_time() {
		return date_time;
	}
	public void setDate_time(String date_time) {
		this.date_time = date_time;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	/**
	 * set Value into ContentValues
	 * @return
	 */
	public ContentValues getValuesSetting() {
		// TODO Auto-generated method stub
		ContentValues values = new ContentValues();
		values.put(DbConstant.PHONE_NUMBER, this.phoneNumber);
		values.put(DbConstant.DATE_TIME, this.getDate_time());
		values.put(DbConstant.STATUS, this.getStatus());
		return values;
	}

	public static CallBlockedItem setValueFromCursor(Cursor c){
		
		CallBlockedItem item = new CallBlockedItem();
		if(c.getColumnIndex(ID)>=0)
			item.setId(c.getInt(c.getColumnIndex(ID)));
		if(c.getColumnIndex(PHONE_NUMBER)>0)
			item.setPhoneNumber(c.getString(c.getColumnIndex(PHONE_NUMBER)));
		if(c.getColumnIndex(DATE_TIME)>0)
			item.setDate_time(c.getString(c.getColumnIndex(DATE_TIME)));
		if(c.getColumnIndex(STATUS)>0)
			item.setStatus(c.getInt(c.getColumnIndex(STATUS)));
		return item;
	}
	
	public String toString(){
		return "CallBlockItem : " + this.getId() + " " + this.getPhoneNumber() + " "+
				this.getDate_time() + " " + this.getStatus();
	}
}
